<?php

use yii\db\Migration;

/**
 * Class m190919_023003_posts_join
 */
class m190919_023003_posts_join extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="发帖中间表"';
        $this->createTable('{{%posts_join}}', [
            'id' => $this->primaryKey(),
            'posts_id' => $this->integer()->notNull()->comment('帖子id'),
            'group_id' => $this->integer()->comment('群组id'),
            'item_id' => $this->integer()->comment('项目id'),
            'movie_id' => $this->integer()->comment('影视学堂id'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('状态'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%posts_join}}');
        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190919_023003_posts_join cannot be reverted.\n";

        return false;
    }
    */
}
